package org.dant.ant.extension.net.processors;

import java.util.*;

import org.dant.ant.extension.net.Processor;
import org.dant.ant.extension.net.DefaultDispatcher;
import org.dant.ant.extension.tasks.internal.RemoteCommand;
import org.dant.ant.extension.tasks.internal.RemoteResponse;
import org.dant.ant.extension.tasks.commands.CommandsConstants;
import org.dant.ant.extension.utils.StringUtils;

public class MonitorProcessor implements Processor {

  public void process(RemoteCommand req, RemoteResponse response) {
    System.out.println("Monitor requied from : " + req.getSourceHost());
    response.setCommandType(req.getName());

    if (CommandsConstants.DANT_CMD_MONITOR.equals(req.getName())) {
      StringBuffer sb = new StringBuffer();
      sb.append("\n-----------Process infomation-----------\n");
      int index = 1;
      sb.append(DefaultDispatcher.getProcessRepository().export());
      response.setResult(sb.toString());
    } else {
      response.setSuccess(false);
      response.setResult("Required a EXEC command , but is not a EXEC command");
    }
  }
}

